package com.yellowpage.omc.datacollect.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.yellowpage.white.common.Constants;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import com.yellowpage.omc.datacollect.data.DataCollectImportLog;
import com.yellowpage.omc.datacollect.dao.DataCollectImportLogDao;

public class DataCollectImportLogServiceImpl extends BaseServiceImpl implements DataCollectImportLogService {
	  private DataCollectImportLogDao dataCollectImportLogDao;
	
	  public void setDataCollectImportLogDao(DataCollectImportLogDao dataCollectImportLogDao) {
		  this.dataCollectImportLogDao = dataCollectImportLogDao;
	  }
	
	
	  /* Smooth generate Method */ 
	  public DataCollectImportLog getDataCollectImportLog(Long id){
	      return dataCollectImportLogDao.get(id);
	  }
	  
    public List<DataCollectImportLog> getAllDataCollectImportLog(){
        return dataCollectImportLogDao.getAll();
    }
    
    public List<Map> queryDataCollectImportLogByPage(Map queryMap, PageRender pageRender) {		
        
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT c.SEQ, b.BATCH_NUM, a.IMPORT_LOG_ID , a.DATA_COLLECT_ID , a.DATA_COLLECT_BATCH_ID ,  a.EVENT , " +
				"a.CREATE_USER , a.CREATE_TIME , a.CONTENT   " +
				" FROM OMC_DATA_COLLECT_IMPORT_LOG a, OMC_DATA_COLLECT c, OMC_DATA_COLLECT_BATCH b  " +
				" WHERE a.DATA_COLLECT_ID = c.DATA_COLLECT_ID "
				+ "   and c.DATA_COLLECT_BATCH_ID = b.DATA_COLLECT_BATCH_ID ")
				.addCondition(" and b.BATCH_NUM = :batchNum ")
				.addCondition(" and c.SEQ = :seq ")
				    			.addCondition(" and IMPORT_LOG_ID = :importLogId ")
							    			.addCondition(" and DATA_COLLECT_ID = :dataCollectId ")
							    			.addCondition(" and DATA_COLLECT_BATCH_ID = :dataCollectBatchId ")
							    			.addCondition(" and C.SEQ = :seq ")
							    			.addCondition(" and EVENT = :event ")
							    			.addCondition(" and CREATE_USER = :createUser ")
							    		    .addCondition(" and date_format(a.CREATE_TIME,'%Y-%m-%d') =  :createTime  ")
		    				    			.addCondition(" and CONTENT = :content ")
							    ; 		    
		    

		List<Map> resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);

		return resultList;
	}
    
    
    public void saveDataCollectImportLog(DataCollectImportLog dataCollectImportLog){
        dataCollectImportLogDao.save(dataCollectImportLog);
    }
    
	  public void updateDataCollectImportLog(DataCollectImportLog dataCollectImportLog){
	      dataCollectImportLogDao.update(dataCollectImportLog);
	  }
	  
	  public void delete(List deleteList){
	      dataCollectImportLogDao.remove(deleteList);
	  }
	  
	  
	 
	
}	